using CLELCore.Assembly.BlobStreams;

namespace CLELCore.Assembly.Descriptors.ClassDescriptors
{
	public class ArrayClassDescriptor : ClassDescriptor
	{
		private byte _array_type;
		public byte ArrayType
		{
			get
			{
				return _array_type;
			}
			set
			{
				_array_type = value;
			}
		}
		private byte _rank;
		public byte Rank
		{
			get
			{
				return _rank;
			}
			set
			{
				_rank = value;
			}
		}
		private byte [] _bounds;
		public byte [] Bounds
		{
			get
			{
				return _bounds;
			}
			set
			{
				_bounds = value;
			}
		}
 
		public ArrayClassDescriptor(byte array_type,byte rank,byte [] bounds) : base(ClassDescriptor.ARRAY_CLASSDESCRIPTOR)
		{
			_array_type = array_type;
			_rank = rank;
			_bounds = bounds;
		}

		public override ClassDescriptor Copy()
		{
			return (ClassDescriptor)new ArrayClassDescriptor(_array_type,_rank,_bounds);
		}

		public override byte [] ToBytes()
		{
			byte [] ret = new byte[_bounds.Length+3];
			ret[0] = BlobElementType.ELEMENT_TYPE_ARRAY;
			ret[1] = _array_type;
			ret[2] = _rank;
			int i;
			for(i = 0;i < _bounds.Length;i++)
				ret[i+3] = _bounds[i];
			return ret;
		}
	}
}
